package sample.plugin.icon;

import android.graphics.drawable.Drawable;

import androidx.core.content.ContextCompat;

import com.rapid.api.framework.ServiceKeys;
import com.rapid.api.framework.common.icon.IconService;
import com.rapid.api.graphics.icon.DrawableIcon;
import com.rapid.api.graphics.icon.Icon;
import com.rapid.framework.program.android.app.AndroidPlugin;

/**
 * Application类
 * 该插件演示了两种方式扩展图标，第一种方式是通过配置实现，可参见插件配置
 * 第二种就是使用api动态扩展图标，可参见本类
 */
public class IconApplication extends AndroidPlugin {
    @Override
    public void activate() {
        //获取图标提供器
        IconService iconService = getService(ServiceKeys.ICON);
        Drawable drawable = ContextCompat.getDrawable(this, R.mipmap.ic_launcher);
        Icon icon = new DrawableIcon(drawable);
        //替换文件夹图标
        iconService.putIcon(IconService.DIRECTORY, icon);
        //为.a和.b后缀文件增加文件类型图标
        iconService.putFileIcon(icon, ".a", ".b");
    }
}
